https://github.com/basilkhuder/Seurat-to-RNA-Velocity#generating-loom-files
import scvelo as scv
import anndata
import pandas as pd
import numpy as np
import matplotlib as plt
import scanpy as sc
import os
import re
import glob
import matplotlib
os.chdir("/scratch/cs/csb/projects/cropseq_nk/")
scv.set_figure_params()
scv.settings.verbosity = 3 # show errors(0), warnings(1), info(2), hints(3)
scv.settings.presenter_view = True # set max width size for presenter view
scv.settings.set_figure_params('scvelo') # for beautified visualization
The problem is that velocyto is counted for individual samples. That's why we need to then also add the merged UMAPs and clusters to the merged .loom objects.
Also, from those .loom objects some of the cells did not survive the QC. That's why we need to remove them
Timepoints_plate1 = scv.read("data/velocyto/new_2023/Timepoints_plate1.loom", cache=False)
Timepoints_plate2 = scv.read("data/velocyto/new_2023/Timepoints_plate2.loom", cache=False)
Variable names are not unique. To make them unique, call `.var_names_make_unique`. Variable names are not unique. To make them unique, call `.var_names_make_unique`.
Timepoints_plate1_expanded_sample_obs = pd.read_csv("data/velocyto/new_2023/Timepoints_plate1Timepoints_plate1_cells.csv")
Timepoints_plate1_expanded_umap_cord = pd.read_csv("data/velocyto/new_2023/Timepoints_plate1Timepoints_plate1_embeddings.csv")
Timepoints_plate1_expanded_cell_clusters = pd.read_csv("data/velocyto/new_2023/Timepoints_plate1Timepoints_plate1_cluster.csv")
Timepoints_plate2_expanded_sample_obs = pd.read_csv("data/velocyto/new_2023/Timepoints_plate2Timepoints_plate2_cells.csv")
Timepoints_plate2_expanded_umap_cord = pd.read_csv("data/velocyto/new_2023/Timepoints_plate2Timepoints_plate2_embeddings.csv")
Timepoints_plate2_expanded_cell_clusters = pd.read_csv("data/velocyto/new_2023/Timepoints_plate2Timepoints_plate2_cluster.csv")
totaltotal_sample_obs = pd.read_csv("data/velocyto/new_2023/totaltotal_cells.csv")
totaltotal_umap_cord = pd.read_csv("data/velocyto/new_2023/totaltotal_embeddings.csv")
totaltotal_cell_clusters = pd.read_csv("data/velocyto/new_2023/totaltotal_cluster.csv")
In this part we remove the QCd cells.
Timepoints_plate1 = Timepoints_plate1[np.isin(Timepoints_plate1.obs.index, Timepoints_plate1_expanded_sample_obs["x"])]
Timepoints_plate2 = Timepoints_plate2[np.isin(Timepoints_plate2.obs.index, Timepoints_plate2_expanded_sample_obs["x"])]
Timepoints_plate1.var_names_make_unique()
Timepoints_plate2.var_names_make_unique()
Variable names are not unique. To make them unique, call `.var_names_make_unique`. Variable names are not unique. To make them unique, call `.var_names_make_unique`. Variable names are not unique. To make them unique, call `.var_names_make_unique`. Variable names are not unique. To make them unique, call `.var_names_make_unique`.
Timepoints_plate_tot = Timepoints_plate1.concatenate(Timepoints_plate2)
tot_expanded_index = pd.DataFrame(Timepoints_plate_tot.obs.index)
totaltotal_umap_cord = totaltotal_umap_cord.rename(columns = {'Unnamed: 0':'CellID'})
tot_expanded_index['CellID'] = tot_expanded_index['CellID'].str.slice(stop=-2)
totaltotal_umap_cord_ordered = tot_expanded_index.merge(totaltotal_umap_cord, on = "CellID")
totaltotal_umap_cord_ordered = totaltotal_umap_cord_ordered.iloc[:,1:]
Timepoints_plate_tot.obsm['X_umap'] = totaltotal_umap_cord_ordered.values
tot_expanded_index = pd.DataFrame(Timepoints_plate_tot.obs.index)
totaltotal_cell_clusters = totaltotal_cell_clusters.rename(columns = {'Unnamed: 0':'CellID'})
tot_expanded_index['CellID'] = tot_expanded_index['CellID'].str.slice(stop=-2)
totaltotal_cell_clusters_ordered = tot_expanded_index.merge(totaltotal_cell_clusters, on = "CellID")
totaltotal_cell_clusters_ordered = totaltotal_cell_clusters_ordered.iloc[:,1:]
Timepoints_plate_tot.obs['clusters_ord'] = totaltotal_cell_clusters_ordered.values
Timepoints_plate_tot.obs
| Clusters | _X | _Y | batch | clusters_ord | |
|---|---|---|---|---|---|
| CellID | |||||
| Timepoints_plate1:AAAGGATCAGCGGTTCx-0 | 0 | 11.025361 | -13.172872 | 0 | Cytokine |
| Timepoints_plate1:AAACGCTTCCCTCAACx-0 | 4 | 47.889122 | -6.541481 | 0 | Activated |
| Timepoints_plate1:AAACGCTAGTTCATGCx-0 | 4 | 21.255173 | 0.206297 | 0 | Early activated |
| Timepoints_plate1:AAAGGTACAGCAGTTTx-0 | 0 | 29.986277 | -20.724464 | 0 | Early activated |
| Timepoints_plate1:AAACCCAGTCACTGATx-0 | 5 | -37.813477 | -10.019014 | 0 | Resting |
| ... | ... | ... | ... | ... | ... |
| Timepoints_plate2:TTTGGTTCACGGCCATx-1 | 7 | -11.732607 | -41.042072 | 1 | Resting |
| Timepoints_plate2:TTTGGTTCAGACAAGCx-1 | 14 | -18.880938 | -18.124798 | 1 | Activated |
| Timepoints_plate2:TTTGGTTGTCCGGACTx-1 | 12 | -15.114505 | 17.845682 | 1 | Resting |
| Timepoints_plate2:TTTGTTGCAGCAGTTTx-1 | 3 | -43.133324 | -12.582972 | 1 | Resting |
| Timepoints_plate2:TTTGTTGCACCTTCGTx-1 | 4 | 19.752218 | -35.777641 | 1 | Type I IFN |
3375 rows × 5 columns
This is the stochastic model
Timepoints_plate_tot=anndata.read_h5ad("results/velocyto/new_2023/Timepoints_plate_tot_scv.h5ad")
scv.pp.filter_and_normalize(Timepoints_plate_tot)
scv.pp.moments(Timepoints_plate_tot)
scv.tl.velocity(Timepoints_plate_tot, mode = "stochastic")
scv.tl.velocity_graph(Timepoints_plate_tot)
scv.pl.velocity_embedding(Timepoints_plate_tot, basis = 'umap')
WARNING: Did not normalize X as it looks processed already. To enforce normalization, set `enforce=True`.
WARNING: Did not normalize spliced as it looks processed already. To enforce normalization, set `enforce=True`.
WARNING: Did not normalize unspliced as it looks processed already. To enforce normalization, set `enforce=True`.
WARNING: Did not modify X as it looks preprocessed already.
computing moments based on connectivities
finished (0:00:06) --> added
'Ms' and 'Mu', moments of un/spliced abundances (adata.layers)
computing velocities
finished (0:00:26) --> added
'velocity', velocity vectors for each individual cell (adata.layers)
computing velocity graph (using 1/24 cores)
finished (0:00:31) --> added
'velocity_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity embedding
finished (0:00:01) --> added
'velocity_umap', embedded velocity vectors (adata.obsm)
scv.pl.proportions(Timepoints_plate_tot, groupby = "clusters_ord", save = "results/velocyto/new_2023/bar_spliced.png")
--------------------------------------------------------------------------- NameError Traceback (most recent call last) /tmp/ipykernel_15795/4101793438.py in <module> ----> 1 scv.pl.proportions(Timepoints_plate_tot, groupby = "clusters_ord", save = "results/velocyto/new_2023/bar_spliced.png") NameError: name 'Timepoints_plate_tot' is not defined
scv.tl.score_genes_cell_cycle(Timepoints_plate_tot)
scv.pl.scatter(Timepoints_plate_tot, color_gradients=['S_score', 'G2M_score'], smooth=True, perc=[5, 95], save = "results/velocyto/new_2023/umap_cell_cycle.png")
calculating cell cycle phase --> 'S_score' and 'G2M_score', scores of cell cycle phases (adata.obs) saving figure to file results/velocyto/new_2023/umap_cell_cycle.png
scv.pl.velocity_embedding_stream(Timepoints_plate_tot,
basis='umap',
color = "clusters_ord",
# color_map="Pastel1",
# palette = ["#2A363B”, “#FF847C”, “#99B898”, “#E84A5F”, “#96281B"],
palette = ["salmon",'#CD8C95',"mediumaquamarine", "darkslategray",'maroon'],
arrow_style = "-|>",
size = 50,
alpha = 1,
linewidth = 1,
dpi = 160,
save = "results/velocyto/new_2023/umap_stream.png")
saving figure to file results/velocyto/new_2023/umap_stream.png
scv.tl.velocity_confidence(Timepoints_plate_tot)
keys = 'velocity_length', 'velocity_confidence'
scv.pl.scatter(Timepoints_plate_tot,
c=keys,
cmap='coolwarm',
perc=[5, 95],
save = "results/velocyto/new_2023/umap_confidence_length.png")
--> added 'velocity_length' (adata.obs) --> added 'velocity_confidence' (adata.obs) saving figure to file results/velocyto/new_2023/umap_confidence_length.png
scv.tl.rank_velocity_genes(Timepoints_plate_tot, groupby='clusters_ord', min_corr=.3)
top_scvelo_genes = scv.DataFrame(Timepoints_plate_tot.uns['rank_velocity_genes']['names'])
top_scvelo_genes.to_csv(path_or_buf = "results/velocyto/new_2023/top_scvelo_genes.csv", index = False)
top_scvelo_genes
ranking velocity genes
finished (0:00:00) --> added
'rank_velocity_genes', sorted scores by group ids (adata.uns)
'spearmans_score', spearmans correlation scores (adata.var)
| Activated | Cytokine | Early activated | Resting | Type I IFN | |
|---|---|---|---|---|---|
| 0 | LINC01934 | ANKRD28 | PHACTR2 | GRAP2 | CMPK2 |
| 1 | AC008105.3 | PTPN22 | BICDL1 | EML4 | USP18 |
| 2 | PTPRJ | NAMPT | TNIP3 | ARHGAP18 | TRIM22 |
| 3 | DLEU2 | CREM | TSPAN5 | PDE7A | TRIM5 |
| 4 | ZNF827 | IL2RA | PPM1G | TC2N | RASGRP3 |
| ... | ... | ... | ... | ... | ... |
| 95 | CENPI | NAB2 | SV2C | RBL2 | IFI6 |
| 96 | GBP1 | ICAM1 | RBPJ | SYNE1 | TNFSF13B |
| 97 | RAD21 | TTF2 | NETO2 | CHEK1 | SORL1 |
| 98 | PRR5L | ZNF331 | LARP1B | CTNNAL1 | NFATC3 |
| 99 | CSF1 | GNG4 | NME1 | HP1BP3 | DUSP2 |
100 rows × 5 columns
scv.pl.velocity(Timepoints_plate_tot,
["PRF1", "GZMB", "FCGR3A", "NCAM1",
"TNF", "IFNG", "CCL3", "CCL4"],
ncols=4,
color = "clusters_ord",
save="results/velocyto/new_2023/scatter_velocity_genes1.png")
saving figure to file results/velocyto/new_2023/scatter_velocity_genes1.png
scv.pl.velocity(Timepoints_plate_tot,
["TNF", "TNFSRF4", "TNFSRF8", "TNFRSF18",
"MX1", "OAS1", "IFIT1", "IFIT3"],
ncols=4,
color = "clusters_ord",
save="results/velocyto/new_2023/scatter_velocity_genes2.png")
saving figure to file results/velocyto/new_2023/scatter_velocity_genes2.png
scv.tl.velocity_pseudotime(Timepoints_plate_tot)
scv.pl.scatter(Timepoints_plate_tot, color='velocity_pseudotime', cmap='gnuplot', save = "results/velocyto/new_2023/umap_pseudotime.png")
saving figure to file results/velocyto/new_2023/umap_pseudotime.png
Timepoints_plate_tot.write("results/velocyto/new_2023/Timepoints_plate_tot_scv.h5ad")
top_genes1 = ["KLRC1", "NCAM1", "GZMK", "GZMA", "KLRB1",
"KLRC2", "GZMH", "LAG3", "HLA-DRA", "TNFRSF18",
"TNFRSF9", "TNFRSF4", "CRTAM", "ENTPD1", "HAVCR2",
"TIGIT", "TNFSF10", "BCL2L11", "ISG15", "OAS1"]
top_genes2 = ["OAS2", "OAS3", "MX1", "MX2", "IRF7",
"IRF9", "EIF2AK2", "CCL3", "CCL4", "TNF",
"IFNG", "CD69"]
scv.pl.scatter(Timepoints_plate_tot, basis=top_genes1, ncols=5, frameon=False,
color = "clusters_ord",
palette = ['red','#CD8C95','#6E8B3D', "#D3D3D3",'darkred'],
save = "results/velocyto/new_2023/scatter_likelohood_olli.png")
saving figure to file results/velocyto/new_2023/scatter_likelohood_olli.png
Here, we use the generalized dynamical model to solve the full transcriptional dynamics. That yields several additional insights such as latent time and identification of putative driver genes.
Timepoints_plate_tot=anndata.read_h5ad("results/velocyto/new_2023/Timepoints_plate_tot_scv.h5ad")
Timepoints_plate_tot_dyn=Timepoints_plate_tot
scv.pp.filter_and_normalize(Timepoints_plate_tot_dyn, enforce=True)
scv.tl.recover_dynamics(Timepoints_plate_tot_dyn)
Normalized count data: X, spliced, unspliced.
WARNING: Did not modify X as it looks preprocessed already.
recovering dynamics (using 1/24 cores)
WARNING: Unable to create progress bar. Consider installing `tqdm` as `pip install tqdm` and `ipywidgets` as `pip install ipywidgets`,
or disable the progress bar using `show_progress_bar=False`.
finished (0:10:09) --> added
'fit_pars', fitted parameters for splicing dynamics (adata.var)
scv.tl.velocity(Timepoints_plate_tot_dyn, mode='dynamical')
scv.tl.velocity_graph(Timepoints_plate_tot_dyn)
computing velocities
finished (0:00:28) --> added
'velocity', velocity vectors for each individual cell (adata.layers)
computing velocity graph (using 1/24 cores)
finished (0:00:08) --> added
'velocity_graph', sparse matrix with cosine correlations (adata.uns)
scv.pl.velocity_embedding_stream(Timepoints_plate_tot_dyn,
basis='umap',
color = "clusters_ord",
palette = ['red','#CD8C95','#6E8B3D', "#D3D3D3",'darkred'],
save = "results/velocyto/new_2023/umap_stream_dyn.png")
computing velocity embedding
finished (0:00:02) --> added
'velocity_umap', embedded velocity vectors (adata.obsm)
saving figure to file results/velocyto/new_2023/umap_stream_dyn.png
scv.tl.velocity_confidence(Timepoints_plate_tot_dyn)
keys = 'velocity_length', 'velocity_confidence'
scv.pl.scatter(Timepoints_plate_tot_dyn,
c=keys,
cmap='coolwarm',
perc=[5, 95],
save = "results/velocyto/new_2023/umap_confidence_length_dyn.png")
--> added 'velocity_length' (adata.obs) --> added 'velocity_confidence' (adata.obs) saving figure to file results/velocyto/new_2023/umap_confidence_length_dyn.png
df = Timepoints_plate_tot_dyn.var
df = df[(df['fit_likelihood'] > .1) & df['velocity_genes'] == True]
kwargs = dict(xscale='log', fontsize=16)
with scv.GridSpec(ncols=3) as pl:
pl.hist(df['fit_alpha'], xlabel='transcription rate', **kwargs)
pl.hist(df['fit_beta'] * df['fit_scaling'], xlabel='splicing rate', xticks=[.1, .4, 1], **kwargs)
pl.hist(df['fit_gamma'], xlabel='degradation rate', xticks=[.1, .4, 1], **kwargs)
df = scv.get_df(Timepoints_plate_tot_dyn, 'fit*', dropna=True)
df.to_csv(path_or_buf="results/velocyto/new_2023/kin_rate_parameters_dyn.csv", index = False)
scv.tl.latent_time(Timepoints_plate_tot_dyn)
scv.pl.scatter(Timepoints_plate_tot_dyn,
color='latent_time',
color_map='gnuplot',
size=80,
save = "results/velocyto/new_2023/umap_latent_time_dyn.png")
computing latent time using root_cells as prior
finished (0:00:19) --> added
'latent_time', shared time (adata.obs)
saving figure to file results/velocyto/new_2023/umap_latent_time_dyn.png
top_genes = Timepoints_plate_tot_dyn.var['fit_likelihood'].sort_values(ascending=False).index[:300]
scv.pl.heatmap(Timepoints_plate_tot_dyn,
var_names=top_genes, sortby='latent_time', col_color='clusters_ord',
n_convolve=100,
save = "results/velocyto/new_2023/heatmap_dyn_likelohood.png")
saving figure to file results/velocyto/new_2023/heatmap_dyn_likelohood.png
top_genes = Timepoints_plate_tot_dyn.var['fit_likelihood'].sort_values(ascending=False).index
scv.pl.scatter(Timepoints_plate_tot_dyn, basis=top_genes[:15], ncols=5, frameon=False,
color = "clusters_ord",
palette = ['red','#CD8C95','#6E8B3D', "#D3D3D3",'darkred'],
save = "results/velocyto/new_2023/scatter_dyn_likelohood.png")
saving figure to file results/velocyto/new_2023/scatter_dyn_likelohood.png
top_genes1 = ["KLRC1", "NCAM1", "GZMK", "GZMA", "KLRB1",
"KLRC2", "GZMH", "LAG3", "HLA-DRA", "TNFRSF18",
"TNFRSF9", "TNFRSF4", "CRTAM", "ENTPD1", "HAVCR2",
"TIGIT", "TNFSF10", "BCL2L11", "ISG15", "OAS1"]
top_genes2 = ["OAS2", "OAS3", "MX1", "MX2", "IRF7",
"IRF9", "EIF2AK2", "CCL3", "CCL4", "TNF",
"IFNG", "CD69"]
scv.pl.scatter(Timepoints_plate_tot_dyn, basis=top_genes1, ncols=5, frameon=False,
color = "clusters_ord",
palette = ['red','#CD8C95','#6E8B3D', "#D3D3D3",'darkred'],
save = "results/velocyto/new_2023/scatter_dyn_likelohood_olli.png")
saving figure to file results/velocyto/new_2023/scatter_dyn_likelohood_olli.png
scv.pl.scatter(Timepoints_plate_tot_dyn, basis=top_genes2, ncols=5, frameon=False,
color = "clusters_ord",
palette = ['red','#CD8C95','#6E8B3D', "#D3D3D3",'darkred'],
save = "results/velocyto/new_2023/scatter_dyn_likelohood_olli2.png")
saving figure to file results/velocyto/new_2023/scatter_dyn_likelohood_olli2.png
scv.tl.rank_dynamical_genes(Timepoints_plate_tot_dyn, groupby='clusters_ord')
df = scv.get_df(Timepoints_plate_tot_dyn, 'rank_dynamical_genes/names')
df.head(5)
df.to_csv("results/velocyto/new_2023/top_scvelo_genes_dyn.csv", index = False)
ranking genes by cluster-specific likelihoods
finished (0:00:04) --> added
'rank_dynamical_genes', sorted scores by group ids (adata.uns)
df.head(20)
| Activated | Cytokine | Early activated | Resting | Type I IFN | |
|---|---|---|---|---|---|
| 0 | NUSAP1 | GNLY | GNLY | NUSAP1 | TMSB4X |
| 1 | ECT2 | NUSAP1 | NDC80 | GNLY | NUSAP1 |
| 2 | TOP2A | SMC4 | TOP2A | TOP2A | EPSTI1 |
| 3 | SMC4 | MKI67 | TMPO | NDC80 | NCAPH |
| 4 | CLEC2D | CENPF | SMC4 | SMC4 | SMC4 |
| 5 | SMC2 | AURKB | NUSAP1 | DIAPH3 | MELK |
| 6 | RBPJ | CDK1 | TMSB4X | TMPO | IFI44L |
| 7 | CRTAM | TMPO | TPX2 | MKI67 | EZH2 |
| 8 | CDK1 | LGALS1 | SPC25 | CIP2A | SMC2 |
| 9 | MKI67 | RRM2 | CLEC2D | CENPE | MX1 |
| 10 | TPX2 | TMSB4X | EZH2 | EZH2 | ESCO2 |
| 11 | PRC1 | PRC1 | HMGN2 | MELK | NCAPG2 |
| 12 | KIF4A | CKAP2L | ATAD2 | KIF11 | OSTF1 |
| 13 | CKAP2L | ESCO2 | CRTAM | TMSB4X | IFI6 |
| 14 | MELK | OSTF1 | MKI67 | TACC3 | KIF4A |
| 15 | TMSB4X | SPC25 | DIAPH3 | LNPEP | RPL5 |
| 16 | NCAPG2 | PTMA | CDK1 | BUB1 | RRM2 |
| 17 | KIF11 | NDC80 | RBPJ | ECT2 | NOP58 |
| 18 | GNLY | HMGN2 | ANP32E | TPX2 | KIF23 |
| 19 | ASPM | CENPE | AURKB | CENPF | DIAPH3 |
for cluster in ["Resting (0)", "Adaptive-like (1)", "Activated (2)", "IFN-stimulated (3)","Cytokine-producing (4)"]:
scv.pl.scatter(expanded_tot_dyn, df[cluster][:5], ylabel=cluster, frameon=False,
save = "results/velocyto/expanded/scatter_dyn_likelihood2.png")
saving figure to file results/velocyto/expanded/scatter_dyn_likelihood2.png
saving figure to file results/velocyto/expanded/scatter_dyn_likelihood2.png
saving figure to file results/velocyto/expanded/scatter_dyn_likelihood2.png
saving figure to file results/velocyto/expanded/scatter_dyn_likelihood2.png
saving figure to file results/velocyto/expanded/scatter_dyn_likelihood2.png
Timepoints_plate_tot_dyn.write("results/velocyto/new_2023/Timepoints_plate_tot_dyn_scv.h5ad")
k562_obs = pd.read_csv("data/velocyto/new_2023/K562K562_cells.csv")
Timepoints_plate_k562 = Timepoints_plate_tot[Timepoints_plate_tot.obs.index.str.slice(stop=-2).isin(k562_obs["x"])]
scv.tl.velocity(Timepoints_plate_k562, mode = "stochastic")
scv.pp.neighbors(Timepoints_plate_k562)
scv.tl.velocity_graph(Timepoints_plate_k562)
scv.pl.velocity_embedding(Timepoints_plate_k562, basis = 'umap')
scv.tl.velocity_confidence(Timepoints_plate_k562)
scv.tl.rank_velocity_genes(Timepoints_plate_k562, groupby='clusters_ord', min_corr=.3)
scv.tl.velocity_pseudotime(Timepoints_plate_k562)
computing velocities
finished (0:00:01) --> added
'velocity', velocity vectors for each individual cell (adata.layers)
computing neighbors
finished (0:00:00) --> added
'distances' and 'connectivities', weighted adjacency matrices (adata.obsp)
computing velocity graph (using 1/24 cores)
finished (0:00:01) --> added
'velocity_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity embedding
finished (0:00:00) --> added
'velocity_umap', embedded velocity vectors (adata.obsm)
--> added 'velocity_length' (adata.obs)
--> added 'velocity_confidence' (adata.obs)
ranking velocity genes
finished (0:00:00) --> added
'rank_velocity_genes', sorted scores by group ids (adata.uns)
'spearmans_score', spearmans correlation scores (adata.var)
scv.pl.velocity_embedding_stream(Timepoints_plate_k562,
basis='umap',
color = "clusters_ord",
# color_map="Pastel1",
# palette = ["#2A363B”, “#FF847C”, “#99B898”, “#E84A5F”, “#96281B"],
palette = ["salmon",'#CD8C95',"mediumaquamarine", "darkslategray",'maroon'],
arrow_style = "-|>",
size = 50,
alpha = 1,
linewidth = 1,
dpi = 160,
save = "results/velocyto/new_2023/umap_stream_k562.png")
saving figure to file results/velocyto/new_2023/umap_stream.png
scv.pl.scatter(Timepoints_plate_k562, color='velocity_pseudotime', cmap='gnuplot', save = "results/velocyto/new_2023/umap_pseudotime_k562.png")
saving figure to file results/velocyto/new_2023/umap_pseudotime_k562.png
Timepoints_plate_k562.write("results/velocyto/new_2023/Timepoints_plate_k562.h5ad")
gdm1_obs = pd.read_csv("data/velocyto/new_2023/GDM1GDM1_cells.csv")
Timepoints_plate_gdm1 = Timepoints_plate_tot[Timepoints_plate_tot.obs.index.str.slice(stop=-2).isin(gdm1_obs["x"])]
scv.tl.velocity(Timepoints_plate_gdm1, mode = "stochastic")
scv.pp.neighbors(Timepoints_plate_gdm1)
scv.tl.velocity_graph(Timepoints_plate_gdm1)
scv.pl.velocity_embedding(Timepoints_plate_gdm1, basis = 'umap')
scv.tl.velocity_confidence(Timepoints_plate_gdm1)
scv.tl.rank_velocity_genes(Timepoints_plate_gdm1, groupby='clusters_ord', min_corr=.3)
scv.tl.velocity_pseudotime(Timepoints_plate_gdm1)
computing velocities
finished (0:00:05) --> added
'velocity', velocity vectors for each individual cell (adata.layers)
computing neighbors
finished (0:00:00) --> added
'distances' and 'connectivities', weighted adjacency matrices (adata.obsp)
computing velocity graph (using 1/24 cores)
finished (0:00:01) --> added
'velocity_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity embedding
finished (0:00:00) --> added
'velocity_umap', embedded velocity vectors (adata.obsm)
--> added 'velocity_length' (adata.obs)
--> added 'velocity_confidence' (adata.obs)
ranking velocity genes
finished (0:00:00) --> added
'rank_velocity_genes', sorted scores by group ids (adata.uns)
'spearmans_score', spearmans correlation scores (adata.var)
scv.pl.velocity_embedding_stream(Timepoints_plate_gdm1,
basis='umap',
color = "clusters_ord",
palette = ["salmon",'#CD8C95',"mediumaquamarine", "darkslategray",'maroon'],
arrow_style = "-|>",
size = 50,
alpha = 1,
linewidth = 1,
dpi = 160,
save = "results/velocyto/new_2023/umap_stream_gdm1.png")
saving figure to file results/velocyto/new_2023/umap_stream_gdm1.png
scv.pl.scatter(Timepoints_plate_gdm1, color='velocity_pseudotime', cmap='gnuplot', save = "results/velocyto/new_2023/umap_pseudotime_gdm1.png")
saving figure to file results/velocyto/new_2023/umap_pseudotime_gdm1.png
Timepoints_plate_gdm1.write("results/velocyto/new_2023/Timepoints_plate_gdm1.h5ad")
ri1_obs = pd.read_csv("data/velocyto/new_2023/RI1RI1_cells.csv")
Timepoints_plate_ri1 = Timepoints_plate_tot[Timepoints_plate_tot.obs.index.str.slice(stop=-2).isin(ri1_obs["x"])]
scv.pl.velocity_embedding_stream(Timepoints_plate_ri1,
basis='umap',
color = "clusters_ord",
palette = ["salmon",'#CD8C95',"mediumaquamarine", "darkslategray",'maroon'],
arrow_style = "-|>",
size = 50,
alpha = 1,
linewidth = 1,
dpi = 160,
save = "results/velocyto/new_2023/umap_stream_ri1.png")
Trying to set attribute `.uns` of view, copying.
saving figure to file results/velocyto/new_2023/umap_stream_ri1.png
scv.pl.scatter(Timepoints_plate_ri1, color='velocity_pseudotime', cmap='gnuplot', save = "results/velocyto/new_2023/umap_pseudotime_ri1.png")
saving figure to file results/velocyto/new_2023/umap_pseudotime_ri1.png
Timepoints_plate_ri1.write("results/velocyto/new_2023/Timepoints_plate_ri1.h5ad")
jurkat_obs = pd.read_csv("data/velocyto/new_2023/JURKATJURKAT_cells.csv")
Timepoints_plate_jurkat = Timepoints_plate_tot[Timepoints_plate_tot.obs.index.str.slice(stop=-2).isin(jurkat_obs["x"])]
scv.pl.velocity_embedding_stream(Timepoints_plate_jurkat,
basis='umap',
color = "clusters_ord",
palette = ["salmon",'#CD8C95',"mediumaquamarine", "darkslategray",'maroon'],
arrow_style = "-|>",
size = 50,
alpha = 1,
linewidth = 1,
dpi = 160,
save = "results/velocyto/new_2023/umap_stream_jurkat.png")
Trying to set attribute `.uns` of view, copying.
saving figure to file results/velocyto/new_2023/umap_stream_jurkat.png
scv.pl.scatter(Timepoints_plate_jurkat, color='velocity_pseudotime', cmap='gnuplot', save = "results/velocyto/new_2023/umap_pseudotime_jurkat.png")
saving figure to file results/velocyto/new_2023/umap_pseudotime_jurkat.png
Timepoints_plate_jurkat.write("results/velocyto/new_2023/Timepoints_plate_jurkat.h5ad")
nk1_obs = pd.read_csv("data/velocyto/new_2023/NK-1NK-1_cells.csv")
Timepoints_plate_nk1 = Timepoints_plate_tot[Timepoints_plate_tot.obs.index.str.slice(stop=-2).isin(nk1_obs["x"])]
scv.pl.velocity_embedding_stream(Timepoints_plate_nk1,
basis='umap',
color = "clusters_ord",
palette = ["salmon",'#CD8C95',"mediumaquamarine", "darkslategray",'maroon'],
arrow_style = "-|>",
size = 50,
alpha = 1,
linewidth = 1,
dpi = 160,
save = "results/velocyto/new_2023/umap_stream_nk1.png")
Trying to set attribute `.uns` of view, copying.
saving figure to file results/velocyto/new_2023/umap_stream_nk1.png
scv.pl.scatter(Timepoints_plate_nk1, color='velocity_pseudotime', cmap='gnuplot', save = "results/velocyto/new_2023/umap_pseudotime_nk1.png")
saving figure to file results/velocyto/new_2023/umap_pseudotime_nk1.png
Timepoints_plate_nk1.write("results/velocyto/new_2023/Timepoints_plate_nk1.h5ad")
nk2_obs = pd.read_csv("data/velocyto/new_2023/NK-2NK-2_cells.csv")
Timepoints_plate_nk2 = Timepoints_plate_tot[Timepoints_plate_tot.obs.index.str.slice(stop=-2).isin(nk2_obs["x"])]
scv.pl.velocity_embedding_stream(Timepoints_plate_nk2,
basis='umap',
color = "clusters_ord",
palette = ["salmon",'#CD8C95',"mediumaquamarine", "darkslategray",'maroon'],
arrow_style = "-|>",
size = 50,
alpha = 1,
linewidth = 1,
dpi = 160,
save = "results/velocyto/new_2023/umap_stream_nk2.png")
Trying to set attribute `.uns` of view, copying.
saving figure to file results/velocyto/new_2023/umap_stream_nk2.png
scv.pl.scatter(Timepoints_plate_nk2, color='velocity_pseudotime', cmap='gnuplot', save = "results/velocyto/new_2023/umap_pseudotime_nk2.png")
saving figure to file results/velocyto/new_2023/umap_pseudotime_nk2.png
Timepoints_plate_nk2.write("results/velocyto/new_2023/Timepoints_plate_nk2.h5ad")